package edu.utwente.sem.hrs.model;

import java.util.HashSet;
import java.util.Set;

/**
 * Represents a person in this Hotel Reservation System
 * 
 * @author Robert Maaskant
 * @author Dennis van der Zwet
 * 
 */
public class Persoon
{
  /**
   * The person's name
   */
  private String naam;
  private String telefoonnummer;
  private String adres;
  /**
   * The roles of this person.
   */
  private Set<PersoonRol> rollen;

  /**
   * Constructor for Person
   * 
   * @param naam
   *          the name of this person
   */
  public Persoon(String naam, String telefoonnummer, String adres)
  {
    this.naam = naam;
    this.telefoonnummer = telefoonnummer;
    this.adres = adres;
    this.rollen = new HashSet<PersoonRol>();
  }

  /**
   * Adds a role to this person's set of roles
   * 
   * @param r
   *          the role to add to this person's set of roles
   */
  public void addRol(PersoonRol r)
  {
    rollen.add(r);
    r.setPersoon(this);
  }

  public String getAdres()
  {
    return adres;
  }

  /**
   * Returns the name of this person
   * 
   * @return the name of this person
   */
  public String getNaam()
  {
    return naam;
  }

  /**
   * Returns the set of roles this person has
   * 
   * @return the set of roles this person has
   */
  public Set<PersoonRol> getRollen()
  {
    return new HashSet<PersoonRol>(rollen);
  }

  public String getTelefoonnummer()
  {
    return telefoonnummer;
  }

  public void setAdres(String adres)
  {
    this.adres = adres;
  }

  public void setTelefoonnummer(String telefoonnummer)
  {
    this.telefoonnummer = telefoonnummer;
  }

  @Override
  public String toString()
  {
    String s = "Persoon [";
    s += "naam: " + naam;
    s += ", telefoonnummer: " + telefoonnummer;
    s += ", adres: " + adres;
    s += ", PersoonRollen [";
    for(PersoonRol r : rollen)
    {
      s += r.toString() + ", ";
    }
    s = s.substring(0, s.length()-2);
    s += "]]";
    return s;
  }

}
